public class If1{
  /* 找出数组中被5整除余1的元素，计算其交错和。
  例如数组元素{6, 0, 11, 1}结果应为6 - 11 + 1 = -4
  */
  static int test(int[] a){
    int sum = 0, cnt = 0;
    for(int i = 0; i < a.length; ++i){
      if(a[i] % 5 == 1 && cnt % 2 == 0){
        sum += a[i];
        ++cnt;
      }
      if(a[i] % 5 == 1 && cnt % 2 != 0){
        sum -= a[i];
        ++cnt;
      }
    }
    return sum;
  }

  public static void main(String[] args){
    int[] a1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    int[] a2 = {6, 0, 11, 1};
    System.out.printf("%d %d\n", test(a1), test(a2));
  }
}